#include<bits/stdc++.h>
using namespace std;
int t,n,m,L;
double V;
double v[100010],a[100010];
int num=0;
int d[100010],p[100010];
int x[100010],nump[1000010],chao[100010];
void did(){

        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]>0)
                x[i]=(V*V-v[i]*v[i])/(2*a[i]);
            else if(a[i]<0)
                x[i]=ceil((V*V-v[i]*v[i])/(2*a[i]))-1;
            else x[i]=0;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
            nump[p[i]]++;
        }
        for(int i=1;i<=n;i++){
            if(a[i]>0){
                for(int j=x[i]+d[i]+1;j<=L;j++){
                    if(nump[j]){
                    chao[i]=1;
                    }
                }
            }else if(a[i]<0){
                if(x[i]<=0)continue;
                for(int j=d[i];j<=d[i]+x[i];j++){
                    if(nump[j]){
                    chao[i]=1;
                    }
                }
            }else{
                if(v[i]>V){
                    for(int j=d[i];j<=L;j++){
                        if(nump[j]){
                        chao[i]=1;
                        }
                    }
                }
            }
        }
}
int main(){
    freopen("detect5.in","r",stdin);
    freopen("detect5.out","w",stdout);
    cin>>t;
    while(t--){
            cin>>n>>m>>L>>V;
            if(n>3000)return 0;
            num=0;
        memset(chao,0,sizeof(chao));
        memset(nump,0,sizeof(nump));
            //memset ?
        did();
        for(int i=1;i<=n;i++){
                if(chao[i])num++;
        }
        cout<<num<<" ";
        cout<<endl;
    }
    fclose(stdin);
    fclose(stdout);
return 0;
}

